// JavaScript Document

function ShowDiv(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;
	// bgdiv.style.height = $(document).height();
	$("#"+bg_div).height($(document).height());
};

function CloseDiv(show_div,bg_div)
{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
};

var price2=0;
var i3 =0;
/*$(function() {
	$.post("goodsServlet","opr=selectCar",function(data1){
	$(".cars").html();
	$(".cars").html(data1.split(",")[0]);
	$(".car_t").html(data1.split(",")[1]);
	$(".price_sum").html(data1.split(",")[2]);
	});
	$(".b_buy").click(function() {window.location.reload();});
	$(".fr").click(function() {window.location.reload();});
});*/

function add(){
	i3 = ($(".numi").attr("id")-(-1));
	var id = $(".content").attr("id");
	var filename = $("#img1").attr("name");
	var name = $(".des_name p").text();
	var price = $(".des_price b").text();
	var score = $(".des_price span").text();
	var gg = "规格:"+$("#myul .checked").text();
	var ys = "颜色:"+$("#myul2 .checked").text();
	var nums =$("#inputid").val();
	var typeid = $(".mytd1 span").text();
	$.post("goodsServlet","opr=add&typeid="+typeid+"&id="+id+"&filename="+filename+"&name="+name+"&price="+price+"&score="+score+"&gg="+gg+"&ys="+ys+"&nums="+nums,function(data){
		var data=JSON.parse(data);
		$(".cars").html();
		$(data).each(function(i){
			$(".cars").append("<li><div class='img'><a href='#'><img src='images/"+this.fileName+"' width='58' height='58' /></a></div><div class='name'><a href='#'>"+this.productName+"</a></div><div class='price'><font color='#ff4e00'>閿燂拷"+this.cost+"</font> X"+this.quantity+"</div></li>");
			price2+=this.cost;
		});
		$(".car_t").html("购物车[ <span >"+i3+"</span> ]");
		$(".price_sum").html("共计&nbsp; <font color='#ff4e00'>￥</font><span>"+price2.toFixed(2)+"</span>");
		ShowDiv_1('MyDiv1','fade1');
		$("#p").html("购物车共有"+i3+"种宝贝&nbsp; &nbsp;  合计："+price2.toFixed(2)+"元");
	});
}

function ShowDiv_1(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;
	// bgdiv.style.height = $(document).height();
	$("#"+bg_div).height($(document).height());
};
//閿熸埅闂鎷烽敓鏂ゆ嫹閿熸枻鎷�
function CloseDiv_1(show_div,bg_div)
{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
};